package routers

import (
	"example.dah.com/controller"
	"example.dah.com/middleware"
	"github.com/gin-gonic/gin"
)

func SetupRouter() *gin.Engine {
	middleware.Log()
	gin.SetMode("release")
	r := gin.Default()

    // 使用中间件
    r.Use(middleware.Cors())

    r.GET("/", controller.IndexHandler)

	apiGroup := r.Group("api")

	{
		apiGroup.POST("/medal", controller.Create)
		apiGroup.GET("/medal", controller.GetList)
		apiGroup.PUT("/medal/:id", controller.Update)
		apiGroup.DELETE("/medal/:id", controller.Del)
	}

	return r
}